<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>
<body>
  <div id="app">
    <p ref="qq" >我是ref</p>
    <button @click="ref">点击</button>
  </div>
    <script>
      const vm = new Vue({
        el:'#app',
        data:{
          arr:['小红','大红']
        },
        methods:{
          ref() {
            // forEach不能终止，短的推荐使用
            console.log(this.$refs.qq);
            this.arr.forEach((item,index) => {
              if (item == '小红') {
                console.log(index);
              }
            }); 
            this.arr.some((item,index)  =>{
              if (item == '小红') {
                console.log(index)
                return true
              }
            })
          }
        }
      })
    </script>
</body>
</html>